package com.logistics.flow.entity.model;

import com.logistics.erp.entity.domain.ErpFlow;
import com.logistics.erp.entity.domain.ErpOrder;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class FlowRow {

    // 任务号
    private String taskCode;
    // 公司编码
    private String companyCode;
    // 零件编码
    private String itemCode;
    // 零件名称
    private String itemName;
    // 交接数量
    private Integer receiveQty;
    // 需求数量
    private BigDecimal planQty;
    // 任务部门
    private String deptCode;


    // 流向工位(班组） 目标工位
    private String wcName;
    // 工作令号
    private String workNo;
    // 客户名称
    private String  customerName;
    // 工序部门
    private String deptNameWc;
    // 下序开工时间
    private String startDte;
    // 直投状态
    private String directPutStatus;

    public FlowRow(){}

    public FlowRow(ErpOrder erpOrder){
        this.companyCode = erpOrder.getCompanyCode();
        this.itemCode = erpOrder.getItemCode();
        this.itemName = erpOrder.getItemName();
        this.receiveQty = erpOrder.getReceiveQty();
        this.taskCode = erpOrder.getShopOrder();
        this.planQty = erpOrder.getQty();
        this.deptCode = erpOrder.getDeptCode();
    }

    public static FlowRow build(ErpOrder erpOrder){
        return new FlowRow(erpOrder);
    }

    public static FlowRow build(ErpFlow erpFlow){
        FlowRow materialPickRow = new FlowRow();
        materialPickRow.setTaskCode(erpFlow.getShopOrder());
        materialPickRow.setWcName(erpFlow.getWcName());
        materialPickRow.setWorkNo(erpFlow.getWorkNo());
        materialPickRow.setCustomerName(erpFlow.getCustomerName());
        materialPickRow.setDeptNameWc(erpFlow.getDeptNameWc());
        materialPickRow.setStartDte(erpFlow.getStartDate());
        materialPickRow.setPlanQty(new BigDecimal(erpFlow.getPlanQty()));
        return materialPickRow;
    }
}
